package EventManager;

import Driver.Facade;
import Model.Booking;
import Model.Person;
import Service.EventClosedException;

public class CreateBookingRequest extends UserRequest 
{

	private Person person;
	private int eventId;
	private int desiredSeatNumber;
	private Booking booking = null;
	
	
	/**
	 * Constructor
	 * @param person The person for which the booking is made
	 * @param eventId The event ID
	 * @param seat The desired seat (can't be guaranteed!)
	 */
	public CreateBookingRequest(Person person, int eventId, int desiredSeatNumber) 
	{
		super();
		this.person = person;
		this.eventId = eventId;
		this.desiredSeatNumber = desiredSeatNumber;
	}

	public Person getPerson() 
	{
		return person;
	}

	public void setPerson(Person person) 
	{
		this.person = person;
	}

	public int getEventId() 
	{
		return eventId;
	}

	public void setEventId(int eventId) 
	{
		this.eventId = eventId;
	}

	public Booking getBooking() 
	{
		return booking;
	}
	
	@Override
	public void process() 
	{
		try 
		{
			Booking b = Facade.getManager().makeBooking(person, eventId, desiredSeatNumber);
			this.booking = b;
			setStatus(RequestStatus.Sustained);
		} 
		catch (EventClosedException e) 
		{
			setStatus(RequestStatus.Refused);
		}
	}

}
